home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 41.zip / BS1 part 41 / Musician disk 3.adf / replay.s < prev    next >
Text File  |  1987-06-04  |  7KB  |  349 lines

  1. ******************************************
  2. * Master Soundtracker V1.0 replayroutine *
  3. * based on V9.0 of DOC *******************
  4. ******************************************
  5.  
  6. * Improved by TIP of The New Masters in JULY 1988 *
  7.  
  8. start:    bsr.s    start_muzak
  9.  
  10. main:    btst    #6,$bfe001
  11.     bne.s    main
  12.  
  13.     bsr.L    stop_muzak
  14.     moveq    #0,d0
  15.     rts
  16.  
  17. start_muzak:
  18.     move.l    #data,muzakoffset    ;** get offset
  19.  
  20. init0:    move.l    muzakoffset,a0        ;** get highest used pattern
  21.     add.l    #472,a0
  22.     move.l    #$80,d0
  23.     clr.l    d1
  24. init1:    move.l    d1,d2
  25.     subq.w    #1,d0
  26. init2:    move.b    (a0)+,d1
  27.     cmp.b    d2,d1
  28.     bgt.s    init1
  29.     dbf    d0,init2
  30.     addq.b    #1,d2
  31.  
  32. init3:    move.l    muzakoffset,a0        ;** calc samplepointers
  33.     lea    pointers(pc),a1
  34.     lsl.l    #8,d2
  35.     lsl.l    #2,d2
  36.     add.l    #600,d2
  37.     add.l    a0,d2
  38.     moveq    #14,d0
  39. init4:    move.l    d2,(a1)+
  40.     clr.l    d1
  41.     move.w    42(a0),d1
  42.     lsl.l    #1,d1
  43.     add.l    d1,d2
  44.     add.l    #30,a0
  45.     dbf    d0,init4
  46.  
  47. init5:    clr.w    $dff0a8            ;** clear used values
  48.     clr.w    $dff0b8
  49.     clr.w    $dff0c8
  50.     clr.w    $dff0d8
  51.     clr.w    timpos
  52.     clr.l    trkpos
  53.     clr.l    patpos
  54.  
  55. init6:    move.l    muzakoffset,a0        ;** initialize timer irq
  56.     move.b    470(a0),numpat+1    ;number of patterns
  57.     move.l    $6c.w,lev3save+2
  58.     move.l    #lev3interrupt,$6c.w
  59.     rts
  60.  
  61. stop_muzak:
  62.     move.l    lev3save+2,$6c.w
  63.     clr.w    $dff0a8
  64.     clr.w    $dff0b8
  65.     clr.w    $dff0c8
  66.     clr.w    $dff0d8
  67.     move.w    #$f,$dff096
  68.     rts
  69.  
  70. lev3interrupt:
  71.     bsr.s    replay_muzak
  72. lev3save:
  73.     jmp    $0
  74.  
  75. replay_muzak:
  76.     movem.l    d0-d7/a0-a6,-(a7)
  77.     addq.w    #1,timpos
  78. speed:    cmp.w    #6,timpos
  79.     beq.L    replaystep
  80.  
  81. chaneleffects:                ;** seek effects
  82.     lea    datach0(pc),a6
  83.     tst.b    3(a6)
  84.     beq.s    ceff1
  85.     lea    $dff0a0,a5
  86.     bsr.s    ceff5
  87. ceff1:    lea    datach1(pc),a6
  88.     tst.b    3(a6)
  89.     beq.s    ceff2
  90.     lea    $dff0b0,a5
  91.     bsr.s    ceff5
  92. ceff2:    lea    datach2(pc),a6
  93.     tst.b    3(a6)
  94.     beq.s    ceff3
  95.     lea    $dff0c0,a5
  96.     bsr.s    ceff5
  97. ceff3:    lea    datach3(pc),a6
  98.     tst.b    3(a6)
  99.     beq.s    ceff4
  100.     lea    $dff0d0,a5
  101.     bsr.s    ceff5
  102. ceff4:    movem.l    (a7)+,d0-d7/a0-a6
  103.     rts
  104.  
  105. ceff5:    move.b    2(a6),d0        ;room for some more
  106.     and.b    #$f,d0            ;implementations below
  107.     tst.b    d0
  108.     beq.s    arpreggiato
  109.     cmp.b    #1,d0
  110.     beq.L    pitchup
  111.     cmp.b    #2,d0
  112.     beq.L    pitchdown
  113.     cmp.b    #12,d0
  114.     beq.L    setvol
  115.     cmp.b    #14,d0
  116.     beq.L    setfilt
  117.     cmp.b    #15,d0
  118.     beq.L    setspeed
  119.     rts
  120.  
  121. arpreggiato:                ;** spread by time
  122.     cmp.w    #1,timpos
  123.     beq.s    arp1
  124.     cmp.w    #2,timpos
  125.     beq.s    arp2
  126.     cmp.w    #3,timpos
  127.     beq.s    arp3
  128.     cmp.w    #4,timpos
  129.     beq.s    arp1
  130.     cmp.w    #5,timpos
  131.     beq.s    arp2
  132.     rts
  133.  
  134. arp1:    clr.l    d0            ;** get higher note-values
  135.     move.b    3(a6),d0        ;   or play original
  136.     lsr.b    #4,d0
  137.     bra.s    arp4
  138. arp2:    clr.l    d0
  139.     move.b    3(a6),d0
  140.     and.b    #$f,d0
  141.     bra.s    arp4
  142. arp3:    move.w    16(a6),d2
  143.     bra.s    arp6
  144. arp4:    lsl.w    #1,d0
  145.     clr.l    d1
  146.     move.w    16(a6),d1
  147.     lea    notetable,a0
  148. arp5:    move.w    (a0,d0.w),d2
  149.     cmp.w    (a0),d1
  150.     beq.s    arp6
  151.     addq.l    #2,a0
  152.     bra.s    arp5
  153. arp6:    move.w    d2,6(a5)
  154.     rts
  155.  
  156. pitchdown:
  157.     bsr.s    newrou
  158.     clr.l    d0
  159.     move.b    3(a6),d0
  160.     and.b    #$f,d0
  161.     add.w    d0,(a4)
  162.     cmp.w    #$358,(a4)
  163.     bmi.s    ok1
  164.     move.w    #$358,(a4)
  165. ok1:    move.w    (a4),6(a5)
  166.     rts
  167.  
  168. pitchup:bsr.s    newrou
  169.     clr.l    d0
  170.     move.b    3(a6),d0
  171.     and.b    #$f,d0
  172.     sub.w    d0,(a4)
  173.     cmp.w    #$71,(a4)
  174.     bpl.s    ok2
  175.     move.w    #$71,(a4)
  176. ok2:    move.w    (a4),6(a5)
  177.     rts
  178.  
  179. setvol:    move.b    3(a6),8(a5)
  180.     rts
  181.  
  182. setfilt:move.b    3(a6),d0
  183.     and.b    #1,d0
  184.     lsl.b    #1,d0
  185.     and.b    #$fd,$bfe001
  186.     or.b    d0,$bfe001
  187.     rts
  188.  
  189. setspeed:
  190.     clr.l    d0
  191.     move.b    3(a6),d0
  192.     and.b    #$f,d0
  193.     move.w    d0,speed+2
  194.     rts
  195.  
  196. newrou:    cmp.l    #datach0,a6
  197.     bne.s    next1
  198.     lea    voi1(pc),a4
  199.     rts
  200. next1:    cmp.l    #datach1,a6
  201.     bne.s    next2
  202.     lea    voi2(pc),a4
  203.     rts
  204. next2:    cmp.l    #datach2,a6
  205.     bne.s    next3
  206.     lea    voi3(pc),a4
  207.     rts
  208. next3:    lea    voi4(pc),a4
  209.     rts
  210.  
  211. replaystep:                ;** work next pattern-step
  212.     clr.w    timpos
  213.     move.l    muzakoffset,a0
  214.     move.l    a0,a3
  215.     add.l    #12,a3            ;ptr to soundprefs
  216.     move.l    a0,a2
  217.     add.l    #472,a2            ;ptr to pattern-table
  218.     add.l    #600,a0            ;ptr to first pattern
  219.     clr.l    d1
  220.     move.l    trkpos,d0        ;get ptr to current pattern
  221.     move.b    (a2,d0),d1
  222.     lsl.l    #8,d1
  223.     lsl.l    #2,d1
  224.     add.l    patpos,d1        ;get ptr to current step
  225.     clr.w    enbits
  226.     lea    $dff0a0,a5        ;chanel 0
  227.     lea    datach0(pc),a6
  228.     bsr.L    chanelhandler
  229.     lea    $dff0b0,a5        ;chanel 1
  230.     lea    datach1(pc),a6
  231.     bsr.L    chanelhandler
  232.     lea    $dff0c0,a5        ;chanel 2
  233.     lea    datach2(pc),a6
  234.     bsr.L    chanelhandler
  235.     lea    $dff0d0,a5        ;chanel 3
  236.     lea    datach3(pc),a6
  237.     bsr.L    chanelhandler
  238.     move.w    #400,d0            ;** wait a while and set len
  239. rep1:    dbf    d0,rep1            ;   of oneshot to 1 word
  240.     move.w    #$8000,d0
  241.     or.w    enbits,d0
  242.     move.w    d0,$dff096
  243.     cmp.w    #1,datach0+14
  244.     bne.s    rep2
  245.     clr.w    datach0+14
  246.     move.w    #1,$dff0a4
  247. rep2:    cmp.w    #1,datach1+14
  248.     bne.s    rep3
  249.     clr.w    datach1+14
  250.     move.w    #1,$dff0b4
  251. rep3:    cmp.w    #1,datach2+14
  252.     bne.s    rep4
  253.     clr.w    datach2+14
  254.     move.w    #1,$dff0c4
  255. rep4:    cmp.w    #1,datach3+14
  256.     bne.s    rep5
  257.     clr.w    datach3+14
  258.     move.w    #1,$dff0d4
  259.  
  260. rep5:    add.l    #16,patpos        ;next step
  261.     cmp.l    #64*16,patpos        ;pattern finished ?
  262.     bne.s    rep6
  263.     clr.l    patpos
  264.     addq.l    #1,trkpos        ;next pattern in table
  265.     clr.l    d0
  266.     move.w    numpat,d0
  267.     cmp.l    trkpos,d0        ;song finished ?
  268.     bne.s    rep6
  269.     clr.l    trkpos
  270. rep6:    movem.l    (a7)+,d0-d7/a0-a6
  271.     rts
  272.  
  273. chanelhandler:
  274.     move.l    (a0,d1.l),(a6)        ;get period & action-word
  275.     addq.l    #4,d1            ;point to next chanel
  276.     clr.l    d2
  277.     move.b    2(a6),d2        ;get nibble for soundnumber
  278.     lsr.b    #4,d2
  279.     beq.s    chan2            ;no soundchange !
  280.     move.l    d2,d4            ;** calc ptr to sample
  281.     lsl.l    #2,d2
  282.     mulu    #30,d4
  283.     lea    pointers-4(pc),a1
  284.     move.l    (a1,d2.l),4(a6)        ;store sample-address
  285.     move.w    (a3,d4.l),8(a6)        ;store sample-len in words
  286.     move.w    2(a3,d4.l),18(a6)    ;store sample-volume
  287.  
  288.     move.l    d0,-(a7)
  289.     move.b    2(a6),d0
  290.     and.b    #$f,d0
  291.     cmp.b    #$c,d0
  292.     bne.s    ok3
  293.     move.b    3(a6),8(a5)
  294.     bra.s    ok4
  295. ok3:    move.w    2(a3,d4.l),8(a5)    ;change chanel-volume
  296. ok4:    move.l    (a7)+,d0
  297.  
  298.     clr.l    d3
  299.     move.w    4(a3,d4),d3        ;** calc repeatstart
  300.     add.l    4(a6),d3
  301.     move.l    d3,10(a6)        ;store repeatstart
  302.     move.w    6(a3,d4),14(a6)        ;store repeatlength
  303.     cmp.w    #1,14(a6)
  304.     beq.s    chan2            ;no sustainsound !
  305.     move.l    10(a6),4(a6)        ;repstart  = sndstart
  306.     move.w    6(a3,d4),8(a6)        ;replength = sndlength
  307. chan2:    tst.w    (a6)
  308.     beq.s    chan4            ;no new note set !
  309.     move.w    22(a6),$dff096        ;clear dma
  310.     tst.w    14(a6)
  311.     bne.s    chan3            ;no oneshot-sample
  312.     move.w    #1,14(a6)        ;allow resume (later)
  313. chan3:    bsr.L    newrou
  314.     move.w    (a6),(a4)
  315.     move.w    (a6),16(a6)        ;save note for effect
  316.     move.l    4(a6),0(a5)        ;set samplestart
  317.     move.w    8(a6),4(a5)        ;set samplelength
  318.     move.w    (a6),6(a5)        ;set period
  319.     move.w    22(a6),d0
  320.     or.w    d0,enbits        ;store dma-bit
  321.     move.w    18(a6),20(a6)        ;volume trigger
  322. chan4:    rts
  323.  
  324. datach0:    blk.w    11,0
  325.         dc.w    1
  326. datach1:    blk.w    11,0
  327.         dc.w    2
  328. datach2:    blk.w    11,0
  329.         dc.w    4
  330. datach3:    blk.w    11,0
  331.         dc.w    8
  332. voi1:        dc.w    0
  333. voi2:        dc.w    0
  334. voi3:        dc.w    0
  335. voi4:        dc.w    0
  336. pointers:    blk.l    15,0
  337. notetable:    dc.w    856,808,762,720,678,640,604,570
  338.         dc.w    538,508,480,453,428,404,381,360
  339.         dc.w    339,320,302,285,269,254,240,226  
  340.         dc.w    214,202,190,180,170,160,151,143
  341.         dc.w    135,127,120,113,000
  342. muzakoffset:    dc.l    0
  343. trkpos:        dc.l    0
  344. patpos:        dc.l    0
  345. numpat:        dc.w    0
  346. enbits:        dc.w    0
  347. timpos:        dc.w    0
  348. data:        blk.b    00000,0
  349.